package cn.zxh.improvement.auth.security.authentication.admin.password;

import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

@Component
public class AdminPasswordProvider implements AuthenticationProvider {

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        AdminPasswordToken adminPasswordToken = (AdminPasswordToken) authentication.getDetails();
        // 这里记性密码校验
        // 成功就设置
        authentication.setAuthenticated(true);
        return authentication;
    }

    @Override
    public boolean supports(Class<?> authentication) {
        return AdminPasswordToken.class.isAssignableFrom(authentication);
    }
}
